﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BarberShop.BLL;
using BarberShop.Model;
using BarberShop.Common.Enum;

public partial class HairstyleManage : BasePage
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetHairstyleType();
            GetStores();
            GetHairstyleData();
           
        }
    }

    protected void btn_search_Click(object sender, EventArgs e)
    {
        GetHairstyleData();
    }

    //getData
    protected void GetHairstyleData()
    {
        HairstyleInfoSearch _search = new HairstyleInfoSearch();
        _search.Name = tx_movieName.Text.Trim();
        _search.StoreId = int.Parse(drp_store.SelectedValue);
        _search.TypeId = int.Parse(DropDownList1.SelectedValue);
        var data = HairstyleInfoBLL.GetHairstyleList(_search);
        this.Grid_Barber.DataSource = data;
        this.Grid_Barber.DataBind();
    }
    //绑定类别
    protected void GetHairstyleType()
    {
        this.DropDownList1.DataSource = HairstyleTypeBLL.GetHairstyleList("");
        this.DropDownList1.DataTextField = "Name";
        this.DropDownList1.DataValueField = "ID";
        this.DropDownList1.DataBind();
        this.DropDownList1.Items.Insert(0, new ListItem { Text = "", Value = "-1" });
    }
    // 状态
    protected string GetStatus(int id)
    {
        int status = UpdateFilesBLL.GetFilesStatus(TableType.HairstyleInfoTable, id);
        switch (status)
        {
            case 0:
                return "正常";
            case 1:
                return "已删除";
            default:
                return "已更新";
        }
    }
    //绑定门店
    protected void GetStores()
    {
        this.drp_store.DataSource = StoresInfoBLL.GetStoresList(new BarberShop.Model.StoresInfoSearch());
        this.drp_store.DataTextField = "StoreName";
        this.drp_store.DataValueField = "ID";
        this.drp_store.DataBind();
        this.drp_store.Items.Insert(0, new ListItem { Text = "", Value = "-1" });
    }
    //获取类别名称
    protected string GetHairstyleTypeName(int id)
    {
        var info=HairstyleTypeBLL.GetHairstyleType(id);
        if (info != null)
            return info.Name;
        return "";
    }
    //翻页
    protected void Grid_Ad_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        this.Grid_Barber.PageIndex = e.NewSelectedIndex;
    }
}